home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Shareware World
/
Utilities
/
Text Processing
/
Alpha
/
Tcl
/
UserCode
/
bibtexOtherAux.tcl
next >
Wrap
Text File
|
1997-05-03
|
6KB
|
187 lines
######################################################################
#
# File: bibtexOtherAux.tcl
#
# Author: Pierre Basso <Pierre.Basso@lim.univ-mrs.fr>
#
# This utility adds a command called "bibtex file.?.aux"
# to the Typeset submenu of the LaTeX menu. This command
# processes .aux files created by the bibunits package
# documented on pages 386--391 of _The LaTeX Companion_ by
# Goossens, Mittelbach, and Samarin [Addison-Wesley, 1994].
#
# To install this utility, do the following:
#
# 1) Open a .tex file.
#
# 2) Pull down the Config menu and choose the command
# "Current Mode:Edit Prefs".
#
# 3) Insert the line
#
# source "$HOME:Tcl:UserCode:bibtexOtherAux.tcl"
#
# into TeXPrefs.tcl.
#
# 4) Restart Alpha.
#
# After adding the 'source' line to TeXPrefs.tcl, the command
# will be automatically inserted into the Typeset submenu
# every time TeX mode is initialized. To disable this utility,
# remove the 'source' line from TeXPrefs.tcl.
#
######################################################################
# Return a modified "Typeset" submenu.
proc typesetSubmenu {} {
global mode
set currentWin [lindex [winNames -f] 0]
if { $currentWin == "" } {
return [minimalTypesetSubmenu]
} elseif { $mode == "TeX" } {
set currentDoc [file tail $currentWin]
# Process an untitled window:
if { [set num [winUntitled]] } {
if { $num > 1 } { set currentDoc "Untitled$num" }
# fall through
}
} else {
return [minimalTypesetSubmenu]
}
set docBasename [file rootname $currentDoc]
set projBasename $docBasename
set currentProj [isWindowInFileset $currentWin "tex"]
if { $currentProj != "" } {
set currentDoc [file tail [texFilesetBaseName $currentProj]]
set docBasename [file rootname $currentDoc]
}
# Determine which menu items are dimmed:
foreach ext {DVI PS AUX IDX Selection} { set prefix$ext "" }
# if { [findAuxiliaryFile DVI] == "" } {
# set prefixDVI "("
# }
# if { [findAuxiliaryFile PS] == "" } {
# set prefixPS "("
# }
# if { [findAuxiliaryFile AUX] == "" } {
# set prefixAUX "("
# }
# if { [findAuxiliaryFile IDX] == "" } {
# set prefixIDX "("
# }
# if { ![isSelection] } {
# set prefixSelection "("
# }
return [list menu -M TeX -n Typeset -m -p typesetSubmenuFilter [list \
[list /TTypeset $currentDoc] \
[list <U<O/V${prefixDVI}View "$docBasename\.dvi"] \
[list <U<O/P${prefixDVI}Print "$docBasename\.dvi"] \
"(-" \
{<U<O/TTypeset Clipboard} \
[list ${prefixSelection}Typeset Selection] \
"(-" \
[list <S${prefixPS}Open "$docBasename\.ps"] \
[list <S${prefixDVI}dvips "$docBasename\.dvi"] \
[list ${prefixPS}View "$docBasename\.ps"] \
[list ${prefixPS}Print "$docBasename\.ps"] \
"(-" \
[list <SOpen "$docBasename\.bbl"] \
[list <S${prefixAUX}bibtex "$docBasename\.aux"] \
[list <E${prefixAUX}bibtex "$docBasename\.\?\.aux"] \
[list <SOpen "$docBasename\.ind"] \
[list <S${prefixIDX}makeindex "$docBasename\.idx"] \
"(-" \
[typesetOtherFilesSubmenu $docBasename $projBasename] \
"(-" \
{Remove Auxiliary Files…} \
{Remove Temporary Files} \
]
]
}
proc typesetSubmenuFilter {submenu item} {
switch -regexp $item {
{Typeset Selection} {set func "typesetSelection"}
{Typeset Clipboard} {set func "typesetClipboard"}
"Typeset.*" {set func "typeset"}
"View.*\.dvi$" {set func {doTypesetCommand view DVI}}
"Print.*\.dvi$" {set func {doTypesetCommand print DVI}}
"dvips.*\.dvi$" {set func {doTypesetCommand dvips DVI}}
"View.*\.ps$" {set func {doTypesetCommand view PS}}
"Print.*\.ps$" {set func {doTypesetCommand print PS}}
{bibtex.*\.\?\.aux$} {set func "bibtexOtherAuxiliary"}
"bibtex.*" {set func {doTypesetCommand bibtex AUX}}
"makeindex.*" {set func {doTypesetCommand makeindex IDX}}
"Open.*\.ps$" {set func {doTypesetCommand open PS}}
"Open.*\.bbl$" {set func {doTypesetCommand open BBL}}
"Open.*\.ind$" {set func {doTypesetCommand open IND}}
"Open.*\.log$" {set func {doTypesetCommand open LOG}}
"Open.*\.aux$" {set func {doTypesetCommand open AUX 1}}
"Open.*\.aux $" {set func {doTypesetCommand open AUX}}
"Open.*\.toc$" {set func {doTypesetCommand open TOC}}
"Open.*\.lof$" {set func {doTypesetCommand open LOF}}
"Open.*\.lot$" {set func {doTypesetCommand open LOT}}
"Open.*\.idx$" {set func {doTypesetCommand open IDX}}
"Open.*\.blg$" {set func {doTypesetCommand open BLG}}
"Open.*\.ilg$" {set func {doTypesetCommand open ILG}}
{Open Any TeX File} {set func "openAnyTeXFile"}
{Remove Auxiliary Files} {set func "removeAuxiliaryFiles"}
{Remove Temporary Files} {set func "removeTemporaryFiles"}
default {set func $item}
}
eval $func
}
proc bibtexOtherAuxiliary {} {
# Test if many bibdata files
set auxiliaryfile [lindex [winNames -f] 0]
set rootauxiliaryfile [file rootname $auxiliaryfile]
set auxiliaryfile $rootauxiliaryfile
append auxiliaryfile ".aux"
if {[file exists $auxiliaryfile] == 0} {
beep
alertnote "No AUX file found!"
return
}
set idaux [open $auxiliaryfile r]
set count -1
while {$count == -1} {
set testeof [gets $idaux buffer]
if {$testeof == -1} then {
beep
alertnote "No bibdata file found!"
return
}
set count [string first "\\bibdata" $buffer]
if {$count >= 0} then {
set bibdata [split $buffer ,]
set len [llength $bibdata]
if {$len == 1} then {
beep
alertnote "No other AUX files found!"
return
}
}
}
# It exists many bibdata and .aux files
# Building the list of all the .aux files
set auxiliaryfile [lindex [winNames -f] 0]
set dirauxiliaryfile [file dirname $auxiliaryfile]
set rootauxiliaryfile [file rootname $auxiliaryfile]
set listauxiliaryfile [glob -nocomplain "$rootauxiliaryfile.?.aux"]
set listauxiliaryfile [map "file tail" $listauxiliaryfile]
# End of building the list of .aux files
#
set selectauxiliary [listpick -p "bibtex:" [lsort $listauxiliaryfile] ]
set filename $dirauxiliaryfile
append filename ":$selectauxiliary"
bibtexAUXFile $filename
}
# Load the new Typeset submenu:
eval [typesetSubmenu]